package com.mediamonks.yalala.data.vo
{
	import temple.core.CoreObject;
	import com.mediamonks.yalala.data.enum.RowStatus;
	import temple.common.interfaces.IOpenable;
	import temple.common.interfaces.IHasStatus;
	import nl.acidcats.yalog.common.MessageData;
	/**
	 * @author Thijs Broerse
	 */
	public class RowData extends CoreObject implements IHasStatus, IOpenable
	{
		public var message:MessageData;
		
		public var original:MessageData;
		
		public var highlighted:Boolean;
		
		public var parent:RowData;
		public var children:Vector.<RowData>;
		
		private var _status:String;

		public function RowData(message:MessageData, original:MessageData = null)
		{
			this.message = message;
			this.original = original || message;
		}

		public function get status():String
		{
			return _status;
		}
		
		public function set status(value:String):void
		{
			_status = value;
		}

		public function open():void
		{
			if (_status == RowStatus.CLOSED) _status = RowStatus.OPENED;
		}

		public function close():void
		{
			if (_status == RowStatus.OPENED) _status = RowStatus.CLOSED;
		}

		public function get isOpen():Boolean
		{
			return _status == RowStatus.OPENED;
		}

		override public function destruct():void
		{
			message = null;
			original = null;
			parent = null;
			children = null;
			
			super.destruct();
		}

	}
}
